﻿package mortal.game.net.command.tower
{
    import Framework.MQ.*;
    import Message.Command.*;
    import Message.Game.*;
    import Message.Public.*;
    import mortal.game.mvc.*;
    import mortal.game.net.broadCast.*;
    import mortal.mvc.core.*;

    public class TowerCopyCommand extends BroadCastCall
    {

        public function TowerCopyCommand(param1:Object)
        {
            super(param1);
            return;
        }// end function

        override public function call(param1:MessageBlock) : void
        {
            var _loc_3:IMessageBase = null;
            var _loc_4:STowerInfo = null;
            var _loc_5:SSeqAttributeUpdate = null;
            var _loc_2:* = param1.messageHead.command;
            _loc_3 = param1.messageBase;
            switch(_loc_2)
            {
                case EPublicCommand._ECmdPublicTowerPass:
                {
                    break;
                }
                case EPublicCommand._ECmdPublicTowerCopyInfo:
                {
                    break;
                }
                case EPublicCommand._ECmdPublicTowerTopListUpdate:
                {
                    NetDispatcher.dispatchCmd(ServerCommand.TowerPublicTowerTopListUpdate, STowerTopListMsg(_loc_3));
                    break;
                }
                case EPublicCommand._ECmdPublicTowerEnd:
                {
                    break;
                }
                case EPublicCommand._ECmdPublicTowerCopy2Pass:
                {
                    NetDispatcher.dispatchCmd(ServerCommand.TowerPublicTowerPass2, STowerCopy2PassMsg(_loc_3));
                    break;
                }
                case EPublicCommand._ECmdPublicTowerCopy2Info:
                {
                    NetDispatcher.dispatchCmd(ServerCommand.TowerPublicTowerCopyInfo2, STowerCopy2Info(_loc_3));
                    break;
                }
                case EPublicCommand._ECmdPublicTowerCopy2End:
                {
                    NetDispatcher.dispatchCmd(ServerCommand.TowerPublicTowerEnd2, null);
                    break;
                }
                case EPublicCommand._ECmdPublicTowerCopy2ScanEnd:
                {
                    NetDispatcher.dispatchCmd(ServerCommand.TowerCopy2ScanEnd, STowerCopy2EndMsg(_loc_3));
                    break;
                }
                case EGateCommand._ECmdGateTower:
                {
                    _loc_4 = _loc_3 as STowerInfo;
                    _cache.copy.tower.towerInfoDic[_loc_4.towerCode] = _loc_4;
                    break;
                }
                case EGateCommand._ECmdGateTowerUpdate:
                {
                    _loc_5 = param1.messageBase as SSeqAttributeUpdate;
                    this.updateAttribute(_loc_5.updates, _loc_5.code);
                    NetDispatcher.dispatchCmd(ServerCommand.TowerInfoUpdate, null);
                    break;
                }
                case EPublicCommand._ECmdPublicTowerCopy2DropEnd:
                {
                    _cache.copy.tower.isDropEnd = true;
                    NetDispatcher.dispatchCmd(ServerCommand.TowerCopy2DropEnd, null);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        private function updateAttribute(param1:Array, param2:int) : void
        {
            var _loc_5:SAttributeUpdate = null;
            var _loc_3:* = param1.length;
            var _loc_4:uint = 0;
            while (_loc_4 < _loc_3)
            {
                
                _loc_5 = param1[_loc_4] as SAttributeUpdate;
                if (_loc_5.attribute)
                {
                    switch(_loc_5.attribute.__value)
                    {
                        case EEntityAttribute._EAttributeTowerPassLevel:
                        {
                            _cache.copy.tower.towerInfoDic[param2.toString()].currentPassLevel = _loc_5.value;
                            break;
                        }
                        case EEntityAttribute._EAttributeTowerMaxPassLevel:
                        {
                            _cache.copy.tower.towerInfoDic[param2.toString()].maxPassLevel = _loc_5.value;
                            break;
                        }
                        case EEntityAttribute._EAttributeTowerScanMoney:
                        {
                            _cache.copy.tower.towerInfoDic[param2.toString()].money[_loc_5.valueStr] = _loc_5.value;
                            break;
                        }
                        case EEntityAttribute._EAttributeTowerResetTimes:
                        {
                            _cache.copy.tower.towerInfoDic[param2.toString()].todayRestTimes = _loc_5.value;
                            break;
                        }
                        default:
                        {
                            break;
                        }
                    }
                }
                _loc_4 = _loc_4 + 1;
            }
            return;
        }// end function

    }
}
